//***************************************************************************
//*
//*	File:			dswl_application.h
//*	Description:	Wrapper for IApplication interface
//*
//***************************************************************************
//*
//*	Note:			This source code is provided "as is" meaning that you may 
//*					use it at your own risk. 
//*					You are free to use it in any way you like.
//*
//***************************************************************************
//*
//*	History:		
//*
//*	-------------------------------------------------------------------------
//*	2003/07/27	|	Initial release									|	rk
//*	-------------------------------------------------------------------------
//*
//***************************************************************************

//
//-------------------------------------------------------------- PREPROCESSOR 
//

#ifndef			_DSWL_APPLICATION_H_INCLUDED
#define			_DSWL_APPLICATION_H_INCLUDED

#if				_MSC_VER > 1000
#pragma once
#ifdef			__SWITCH_SHOW_HEADER
#pragma message ("-- dswl_application.h\n")
#endif
#ifdef			__SWITCH_SHOW_HEADER_TREE
#pragma message ("-- "__FILE__"\n")
#endif
#endif 

#ifdef			_DSWL_SWITCH_USE_AUTOCAST
#ifdef			_DSWL_SWITCH_USE_UNSAFE_AUTOCAST
#pragma	message ( "-- dswl_application.h \t Warning: Generating auto-cast operator: CIApplication::operator IApplication* () const" )
#else
#pragma	message ( "-- dswl_application.h \t Warning: Generating auto-cast operator: CIApplication::operator       IApplication* ()" )
#pragma	message ( "-- dswl_application.h \t Warning: Generating auto-cast operator: CIApplication::operator const IApplication* () const" )
#endif
#endif

//
//-------------------------------------------------------------- DEPENDENCIES
//

//
//------------------------------------------------------ FORWARD DECLARATIONS
//

class			CIWindows			;
class			CIDocuments			;
class			CIProjects			;
class			CIGenericWindow		;
class			CIGenericDocument	;
class			CIGenericProject	;
class			CIConfiguration		;
class			CITextEditor		;
class			CIDebugger			;

//
//--------------------------------------------------------- CLASS DECLARATION
//

//***************************************************************************
//**	@DOC		CLASS CIApplication
//***************************************************************************
//*		@CLASS		Wrapper for IApplication interface
//***************************************************************************
class _DSWL_EXT_CLASS CIApplication  
{
	//																								
	//-----------------------------------------------------------------------						
	//***************************     ATTRIBS     ***************************						
	//-----------------------------------------------------------------------						
	//																								
private:																														// @ACCESS	Private Attributes	
			CComPtr< IApplication >	m_pIApplication	;																			// @CMEMBER	Smart pointer to the actual text document interface
																														
	//																																	
	//-----------------------------------------------------------------------															
	//*************************     PROPERTIES     **************************									
	//-----------------------------------------------------------------------															
	//																																	
public:																															// @ACCESS	Public Property Methods
			BOOL					IsActive				( void )												const	;	// @CMEMBER	Determines whether the application is active
			BOOL					IsVisible				( void )												const	;	// @CMEMBER	Determines whether the application is visible
																													
			DsWindowState			GetWindowState			( void )												const	;	// @CMEMBER	Returns the application's window state
			CRect					GetWindowRect			( void )												const	;	// @CMEMBER	Returns the application's window rect
			CString					GetFullName				( void )												const	;	// @CMEMBER	Returns the application's full name
			CString					GetName					( void )												const	;	// @CMEMBER	Returns the application's name
			CString					GetVersion				( void )												const	;	// @CMEMBER	Returns the application's version
			CString					GetPath					( void )												const	;	// @CMEMBER	Returns the application's path
			CString					GetCurrentDirectory		( void )												const	;	// @CMEMBER	Returns the application's current directory
																													
			CIWindows				GetWindows				( void )												const	;	// @CMEMBER	Returns the application's windows
			CIDocuments				GetDocuments			( void )												const	;	// @CMEMBER	Returns the application's documents
			CIProjects				GetProjects				( void )												const	;	// @CMEMBER	Returns the application's projects
			CITextEditor			GetTextEditor			( void )												const	;	// @CMEMBER	Returns the application's text editor
			CIDebugger				GetDebugger				( void )												const	;	// @CMEMBER	Returns the application's debugger
			CIGenericWindow			GetActiveWindow			( void )												const	;	// @CMEMBER	Returns the application's active window
			CIGenericDocument		GetActiveDocument		( void )												const	;	// @CMEMBER	Returns the application's active document
			CIGenericProject		GetActiveProject		( void )												const	;	// @CMEMBER	Returns the application's active project
			CIConfiguration			GetActiveConfiguration	( void )												const	;	// @CMEMBER	Returns the application's configuration
																												
			void					SetActive				(		BOOL				a_bActive				)			;	// @CMEMBER	Activates or deactivates the application
			void					SetVisible				(		BOOL				a_bVisible				)			;	// @CMEMBER	Shows or hides the application
			void					SetWindowState			(		DsWindowState		a_enuState				)			;	// @CMEMBER	Sets the application's window state
			void					SetWindowRect			( const	CRect&				a_rectWindow			)			;	// @CMEMBER	Sets the application's window rect
			void					SetCurrentDirectory		( const	CString&			a_strPath				)			;	// @CMEMBER	Sets the application's current directory
																															
			void					SetActiveProject		(		IGenericProject*	a_pIProject				)			;	// @CMEMBER	Sets the application's active project
			void					SetActiveConfiguration	(		IConfiguration*		a_pIConfig				)			;	// @CMEMBER	Sets the application's active configuration
																												
	//																																
	//-----------------------------------------------------------------------														
	//*************************     INFORMATION     *************************									
	//-----------------------------------------------------------------------														
	//																																
public:																															// @ACCESS	Public Information Methods
			BOOL					IsNull					( void )												const	;	// @CMEMBER	Determines whether the internal pointer is <t NULL>
			BOOL					IsValid					( void )												const	;	// @CMEMBER	Determines whether the internal pointer differs from <t NULL>
																												
	//																																
	//-----------------------------------------------------------------------														
	//**************************     EXECUTION     **************************									
	//-----------------------------------------------------------------------														
	//																																
public:																															// @ACCESS	Public Execution Methods
			void					EnableModeless			(		BOOL				a_bEnable				)			;	// @CMEMBER	Enables or disables modeless mode
			void					ExecuteCommand			( const	CString&			a_strCommand			)			;	// @CMEMBER	Executes the specified command
			void					PrintToOutputWindow		( const	CString&			a_strMessage			)			;	// @CMEMBER	Prints the specified message to the output window
			void					Quit					( void )														;	// @CMEMBER	Quits the application

	//																																
	//-----------------------------------------------------------------------														
	//****************************     BUILD     ****************************									
	//-----------------------------------------------------------------------														
	//																																
public:																															// @ACCESS	Public Build Methods
			void					Clean					(		IConfiguration*		a_pIConfig				)			;	// @CMEMBER	Cleans the specified configuration and all of its dependencies
			void					Build					(		IConfiguration*		a_pIConfig				)			;	// @CMEMBER	Builds the specified configuration and all of its dependencies
			void					RebuildAll				(		IConfiguration*		a_pIConfig				)			;	// @CMEMBER	Rebuilds the specified configuration and all of its dependencies
			void					Execute					(		IConfiguration*		a_pIConfig				)			;	// @CMEMBER	Executes the specified configuration
																												
			long					GetErrors				( void )												const	;	// @CMEMBER	Determines the number of errors that occured during the last build
			long					GetWarnings				( void )												const	;	// @CMEMBER	Determines the number of errors that occured during the last build
																												
	//																														
	//-----------------------------------------------------------------------												
	//*********************     PROJECT MANAGEMENT     **********************
	//-----------------------------------------------------------------------												
	//																														
public:																															// @ACCESS	Public Project Management Methods
			void					AddProject				( const	CString&			a_strName							
															, const CString&			a_strPath							
															, const CString&			a_strType							
															,		BOOL				a_bAddDefaultFolders	)			;	// @CMEMBER	Adds the specified project ot the current workspace

	//																														
	//-----------------------------------------------------------------------												
	//**********************     ADDIN MANAGEMENT     ***********************
	//-----------------------------------------------------------------------												
	//																														
public:																															// @ACCESS	Public AddIn Management Methods
			BOOL					AddCommand				( const	CString&			a_strName				
															, const CString&			a_strMethodName			
															,		long				a_lBitmapOffset			
															,		DWORD				a_dwCookie				)			;	// @CMEMBER	Adds the specified command
			void					AddCommandBarButton		(		long				a_lButtonType			
															, const	CString&			a_strName				
															,		DWORD				a_dwCookie				)			;	// @CMEMBER	Adds the specified button to the command bar
			void					AddKeyBinding			( const CString&			a_strKey				
															, const CString&			a_strCommand			
															, const CString&			a_strEditor				)			;	// @CMEMBER	Adds the specified key binding
			void					SetAddInInfo			(		HINSTANCE			a_hInstance
															,		IDispatch*			a_pIDispatchCmd
															,		long				a_lIDBitmapResMedium
															,		long				a_lIDBitmapResLarge
															,		DWORD				a_dwCookie				)			;	// @CMEMBER	Registers the specified AddIn
			IDispatch*				GetPackageExtension		( const CString&			a_strExtensionName		)			;	// @CMEMBER	Determines the dispatch interface for the specified extension package

	//																												
	//-----------------------------------------------------------------------										
	//**************************     OPERATORS     **************************										
	//-----------------------------------------------------------------------										
	//																												
public:																															// @ACCESS	Public Operators
			bool					operator	==			( const CIApplication&			a_Other				)	const	;	// @CMEMBER	Comparison operator
			bool					operator	!=			( const CIApplication&			a_Other				)	const	;	// @CMEMBER	Comparison operator
			bool					operator	<=			( const CIApplication&			a_Other				)	const	;	// @CMEMBER	Comparison operator
			bool					operator	>=			( const CIApplication&			a_Other				)	const	;	// @CMEMBER	Comparison operator
			bool					operator	<			( const CIApplication&			a_Other				)	const	;	// @CMEMBER	Comparison operator
			bool					operator	>			( const CIApplication&			a_Other				)	const	;	// @CMEMBER	Comparison operator
																												
			CIApplication&			operator	=			(		IApplication*			a_pIOther			)			;	// @CMEMBER	Copy operator
																												
			IApplication*			operator	*			( void )														;	// @CMEMBER	Dereference operator
	const	IApplication*			operator	*			( void )												const	;	// @CMEMBER	Dereference operator
																												
			IApplication*			operator	->			( void )														;	// @CMEMBER	Member access operator
	const	IApplication*			operator	->			( void )												const	;	// @CMEMBER	Member access operator
																												
	#ifdef	_DSWL_SWITCH_USE_AUTOCAST																			
	#ifdef	_DSWL_SWITCH_USE_UNSAFE_AUTOCAST																	
									operator				IApplication*	( void )								const	;	// @CMEMBER	TypeCast operator
	#else																										
									operator				IApplication*	( void )										;	// @CMEMBER	TypeCast operator
									operator	const		IApplication*	( void )								const	;	// @CMEMBER	TypeCast operator
	#endif																										
	#endif																										
																												
	//																											
	//-----------------------------------------------------------------------									
	//***********************     CON/DESTRUCTION     ***********************									
	//-----------------------------------------------------------------------									
	//																											
public:																															// @ACCESS	Public Con-/Destruction Methods	
			 CIApplication( IApplication* a_pIApplication = NULL );																// @CMEMBER	Default constructor
	virtual ~CIApplication();																									// @CMEMBER	Default destructor
};
//***************************************************************************
//**	@END
//***************************************************************************

#endif		// _DSWL_APPLICATION_H_INCLUDED
